﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Wolfy.NetDisk.Core.Model;
using Wolfy.NetDisk.Core.Repository;
using Wolfy.NetDisk.Core.Service;

namespace Wolfy.NetDisk.Service
{
    public class FileService : CRUDService<File>, IFileService
    {
        public FileService(IRepository<File> repository)
            : base(repository)
        { }
        /// <summary>
        /// 文件已经存在多少个
        /// </summary>
        /// <returns></returns>
        public int HowManyFileExists(File file, User user)
        {
            return this.repository.Where(x => x.Md5 == file.Md5 && x.User.Id == user.Id && x.Ext == file.Ext && x.Folder.Id == file.Folder.Id).Count();
        }
    }
}
